package com.js.rtu.config;

import java.util.ArrayList;
import java.util.List;

/**
 * 表三、终端通信接口参数设置表
 * 采集使能
 * Created by wz on 2020/6/18.
 */
public class EnableConfig {
    private static final int TYPE_NOT_ALLOW = 0;
    private static final int TYPE_ALLOW = 1;
    private static final int TYPE_OPEN = 170;
    private static final int TYPE_CLOSE = 85;
    private static final int TYPE_ERR= 2;

    private static final String ENABLE_ALLOW = "允许";
    private static final String ENABLE_NOT_ALLOW = "禁止";
    private static final String ENABLE_CLOSE = "关闭";
    private static final String ENABLE_OPEN = "开启";
    private static final String ENABLE_ERR = "未知状态";

    /**
     * 使能状态
     *
     * @param type 代码
     * @return 状态
     */
    public static String getEnable(int type) {
        String enable = ENABLE_ERR;
        switch (type) {
            case TYPE_ALLOW:
                enable = ENABLE_ALLOW;
                break;
            case TYPE_NOT_ALLOW:
                enable = ENABLE_NOT_ALLOW;
                break;
            case TYPE_OPEN:
                enable = ENABLE_OPEN;
                break;
            case TYPE_CLOSE:
                enable = ENABLE_CLOSE;
                break;

        }
        return enable;
    }

    /**
     * 使能状态
     *
     * @param state 状态
     * @return  代码
     */
    public static int getEnable(String state) {
        int enable = TYPE_ERR;
        switch (state) {
            case ENABLE_ALLOW:
                enable =TYPE_ALLOW ;
                break;
            case ENABLE_NOT_ALLOW:
                enable = TYPE_NOT_ALLOW;
                break;
            case ENABLE_OPEN:
                enable = TYPE_OPEN;
                break;
            case ENABLE_CLOSE:
                enable = TYPE_CLOSE;
                break;


        }
        return enable;
    }


    /**
     * 获取使能状态列表集合
     * @return 使能状态集合
     */
    public static List<String> getEnableList() {
        List<String> list = new ArrayList<>();
        list.add(ENABLE_ALLOW);
        list.add(ENABLE_NOT_ALLOW);
        list.add(ENABLE_OPEN);
        list.add(ENABLE_CLOSE);
        return  list;
    }


}
